<?php

namespace App\Entity;

use App\Repository\OrganizationRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=OrganizationRepository::class)
 * @ORM\Table(options={"comment":"组织架构表"})
 * @ORM\HasLifecycleCallbacks()
 */
class Organization {
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="integer", nullable=true, options={"comment":"父级ID"})
     */
    private $parent_id;

    /**
     * @ORM\Column(type="string", length=255, options={"comment":"名称"})
     */
    private $name;

    /**
     * @ORM\Column(type="string", length=255, nullable=true, options={"comment":"描述"})
     */
    private $description;

    /**
     * @ORM\Column(type="integer", nullable=true, options={"comment":"管理者ID"})
     */
    private $manage_id;

    /**
     * @ORM\Column(type="boolean", nullable=true, options={"default":"1", "comment":"状态 0禁用 1启用"})
     */
    private $status = true;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $created_at;

    /**
     * @ORM\Column(type="datetime", nullable=true)
     */
    private $updated_at;

    public function getId (): ?int {
        return $this->id;
    }

    public function getParentId (): ?int {
        return $this->parent_id;
    }

    public function setParentId (?int $parent_id): self {
        $this->parent_id = $parent_id;

        return $this;
    }

    public function getName (): ?string {
        return $this->name;
    }

    public function setName (string $name): self {
        $this->name = $name;

        return $this;
    }

    public function getDescription (): ?string {
        return $this->description;
    }

    public function setDescription (?string $description): self {
        $this->description = $description;

        return $this;
    }

    public function getManageId (): ?int {
        return $this->manage_id;
    }

    public function setManageId (?int $manage_id): self {
        $this->manage_id = $manage_id;

        return $this;
    }

    public function getStatus (): ?bool {
        return $this->status;
    }

    public function setStatus (?bool $status): self {
        $this->status = $status;

        return $this;
    }

    public function getCreatedAt (): ?\DateTimeInterface {
        return $this->created_at;
    }

    public function setCreatedAt (?\DateTimeInterface $created_at): self {
        $this->created_at = $created_at;

        return $this;
    }

    public function getUpdatedAt (): ?\DateTimeInterface {
        return $this->updated_at;
    }

    public function setUpdatedAt (?\DateTimeInterface $updated_at): self {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * 新建之前
     * @ORM\PrePersist()
     */
    public function prePersistHook () {
        // 添加创建时间
        $this->created_at = new \DateTime();
    }

    /**
     * 更新之前
     * @ORM\PreUpdate()
     */
    public function preUpdateHook () {
        // 添加更新时间
        $this->updated_at = new \DateTime();
    }
}
